/**
 * 
 */
package info.niwota.profile;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

/**
 * @author qiangli
 * 
 */
public class BootReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {
		if (intent.getAction() != null) {
			if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
				SharedPreferences sp = PreferenceManager
						.getDefaultSharedPreferences(context);
				String key = context.getString(R.string.settings_boot_toggle_key).toString();
				boolean bootstart = sp.getBoolean(key, false);
				if (bootstart == true)  {
					context.startService(new Intent(context, MainActivity.class));
				}
			}
		}
	}
}
